<template>
  <div>
    <el-row :gutter="16">
      <el-col :span="12">
        <el-card :loading="btnLoading">
          <div slot="header" class="flex jc-between"><span>修改ICP</span> <el-button class="" @click="submit" type="primary"> 保存 </el-button></div>
          <el-form label-width="120px" :model="form">
            <el-form-item label="官网标题：">
              <el-input type="text" v-model="form.title"></el-input>
            </el-form-item>
            <el-form-item label="ICP备案：">
              <el-input type="text" v-model="form.ICP"></el-input>
            </el-form-item>
            <el-form-item label="copyright：">
              <el-input type="text" v-model="form.copyright"></el-input>
            </el-form-item>
            <el-form-item label="底部文字：">
              <el-input type="textarea" rows="5" v-model="form.bottomText"></el-input>
            </el-form-item>
          </el-form>
        </el-card>
      </el-col>
      <el-col :span="12"></el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {},
      btnLoading: false,
    };
  },
  methods: {
    submit() {
      this.btnLoading = true;
      this.$api.put("/Config", this.form).then(({ data }) => {
        if (data.Code == 200) this.$message.success(data.Msg);
        else this.$message.error(data.Msg);
        this.btnLoading = false;
        this.getInfo();
      });
    },
    getInfo() {
      this.$api.get("/Config").then(({ data }) => {
        this.form = data;
      });
    },
  },
  mounted() {
    this.getInfo();
    console.log(this.$headers);
  },
};
</script>
